<%@ include file = "templates/header.jsp" %>
<%@ page import = "clothing.database.SaleManager" %>
<%@ page import = "clothing.database.Sale" %>
<%@ page import = "clothing.database.EmployeeManager" %>
<%@ page import = "clothing.database.Employee" %>
<%@ page import = "java.util.ArrayList" %>

<h3> Sales Page </h3>


<%@ include file="templates/main_nav.jsp" %>

<%
	SaleManager sm = new SaleManager();
	ArrayList<Sale> list = sm.getList();
	
	out.println("<form name =\"myform\" id=\"myform\" action =\"deleteItems.jsp\" method=\"post\">");
	out.println("<table>");
	%>
	<tr>
		<td><strong>Employee ID</strong></td>
		<td><strong>Item ID</strong></td>
		<td><strong>Purchase Price</strong></td>
		<td><strong>Purchase Date</strong></td>		
	</tr>
	<input type="hidden" name ="id" id = "id" />	
	
	<% 
	
	for(int i=0;i<list.size();i++)
	{
		out.println("<tr>");
		Sale current = list.get(i);
			out.println("<td>"+ current.getId()+"</td>");
			out.println("<td>"+ current.getItem_ID()+"</td>");
			out.println("<td>"+ current.getPurchasePrice()+"</td>");
			out.println("<td>"+ current.getPurchaseDate()+"</td>");			
			
		out.println("</tr>");
	}
	

	out.println("</table></form>");
	
	
%>

<h2> Add a Sale Entry </h2>
<form action ="addSale.jsp" method = "post" >
	<table>
		<tr>
			<td>Employee ID: </td>
            <td>
                 <select name="uid" />
                 <% 
                 out.println("<option> Please Select </option>");
                EmployeeManager em =  new EmployeeManager();
                ArrayList<Employee> listE = em.getList();
                for(int i=0;i<listE.size();i++)
            	{
            		Employee current = listE.get(i);
            		int idS = current.getId();
            		String ID = Integer.toString(idS);
            	    out.println("<option value=\""+ID+"\">"+ ID+"</option>");
            	}
                
                
                %>
                 </select>
            </td>
		</tr>

		<tr>
			<td>Item ID: </td><td><input type="text" name="item_id" /></td>
		</tr>

		<tr>
			<td>Purchase Price: </td><td><input type="text" name="purchase_p" /></td>
		</tr>

        <tr>
			<td>Purchase Date: </td><td><input type="text" name="purchase_d" /></td>
		</tr>
		
		<tr>
			<td> </td><td><input type="submit" value= "submit" /></td>
		</tr>
	</table>
	</form>

<%@ include file = "templates/footer.jsp" %>

